<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<%@ taglib uri="/WEB-INF/tld/sys.tld" prefix="sys" %> 
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>流程表单权限配置</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>
<body class="iframeBody">
<div class="Wrapper">
	<form id="div_auth_form">
		<input name="procDefKey" id="procDefKeyId" type="text" style="display: none;" value="${procDefKey}"/>
        <input name="procDefId" id="procDefIdId" type="text" style="display: none;" value="${procDefId}"/>
        <input name="procInstId" id="procInstIdId" type="text" style="display: none;" value="${procInstId}"/>
        <input name="taskId" id="taskIdId" type="text" style="display: none;" value="${taskId}"/>
        <input name="taskDefKey" id="taskDefKeyId" type="text" style="display: none;" value="${taskDefKey}"/>
        <input name="preTaskId" id="preTaskIdId" type="text" style="display: none;" value="${preTaskId}"/>
        <input name="dataId" id="dataIdId" type="text" style="display: none;" value="${dataId}"/>
        <input name="branchKey" id="branchKeyId" type="text" style="display: none;" value="${branchKey}"/>
        <div class="fieldset1 tabel_col tabel_col_s clearFix noBorder">
		   <c:forEach items="${flowFormAuthConfigList }" var="kv" begin="0" step="1" varStatus="status">
		     <input type="checkbox" value="${kv.key }" name="authFormItem"><span>${kv.value }</span><br/>
		   </c:forEach>
		</div>
    </form>
    
    <%-- <sys:FlowFrmAth dataId="${dataId}" preTaskIds="${preTaskId}" athCd="addVisitsMaterial" pInstId="${procInstId}">
    	成功了
    </sys:FlowFrmAth> --%>
    
</div>

<script type="text/javascript">
	$(function () {
	    initForm();
	});
	
	//初始化表单
	function initForm(){
		$("#div_auth_form").ligerForm();
	}
	
	//父类保存
	frameElement.dialog.onOk = function (callback, btnName) {
		//保存表单数据,并且回调任务完成方法.
        var form = liger.get("div_auth_form");
		var data = form.getData();
		//获取未选中的
		var authFormItem = [];
		$('input[name="authFormItem"]').not("input:checked").each(function(){
			var val = $(this).val();
		    var nm = $(this).parent().next().html();
		    authFormItem.push({"athCd":val, "athCdNm":nm});
		});  
		data["authFormItem"] = JSON.stringify(authFormItem);
		//获取已经选中的
		var authFormCheckedItem = [];
		$('input[name="authFormItem"]:checked').each(function(){
			var val = $(this).val();
		    var nm = $(this).parent().next().html();
		    authFormCheckedItem.push({"athCd":val, "athCdNm":nm});
		});
		data["authFormCheckedItem"] = JSON.stringify(authFormCheckedItem);
		
		$.ligerDialog.SQconfirm("确定" + btnName + "吗?.", function (flag) {
    		if(flag == false)return;
    		//alert(JSON.stringify(data));
    		var _url = '<%=path%>/flow/flowfrmathrec/addAndModify.do';
    		AjaxUtils.ajaxPost(_url, data, function(msg){
    			if(msg.success == 1){
    				callback(true);
       			 }else{
       				UIUtils.alertError(msg.info);
       			 }
       	    },true);
		});
	}
	
	//父类关闭窗口
	frameElement.dialog.onCancel = function () {
		frameElement.dialog.close();
	}


</script>

</body>
</html>